/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package networkrespnse;

import core.ParameterDecoder;
import utils.Utils;
/**
 *
 * @author Kvest
 */
public class WorkReportResponse extends Response
{
    private String[] items;

    public WorkReportResponse(byte[] data)
    {
        super(WORK_REPORT_RESPONSE);
        items = null;
        
        parse(data);
    }

    protected void parse(byte[] data)
    {
        byte[] body,temp;
        int index,count;
        //��������  body
        body = ParameterDecoder.getTransferBody(data);
        //������������� ��������
        temp = new byte[4];
        index = 0;
        for (int i=0;i<4;i++)
        {
                temp[i] = body[index++];
        }
        index += Utils.byteToInt(temp);
        //������ �������
        for (int i=0;i<4;i++)
        {
                temp[i] = body[index++];
        }
        count = Utils.byteToInt(temp);

        items = new String[count+1];
        temp = new byte[8];

        //���� "�"
        for (int j=0;j<count;j++)
        {
                for (int i=0;i<8;i++)
                {
                        temp[i] = body[index++];
                }
                items[j] = Utils.dateToString(Utils.byteToDate(temp)) + " - ";
        }

        for (int i=0;i<4;i++)
        {
                temp[i] = body[index++];
        }

        //���� "��"
        for (int j=0;j<count;j++)
        {
                for (int i=0;i<8;i++)
                {
                        temp[i] = body[index++];
                }
                items[j] += Utils.dateToString(Utils.byteToDate(temp)) + "(";
        }

        for (int i=0;i<4;i++)
        {
                temp[i] = body[index++];
        }
        temp = new byte[4];

        //���������� �����
        for (int j=0;j<count;j++)
        {
                for (int i=0;i<4;i++)
                {
                        temp[i] = body[index++];
                }
                items[j] += Utils.byteToInt(temp)+" ";
        }

        //����� �����
        for (int i=0;i<4;i++)
        {
                temp[i] = body[index++];
        }
        items[count] = Integer.toString(Utils.byteToInt(temp));
    }

    public String[] getItems()
    {
        return items;
    }
}
